#include <iostream>
#include <stdlib.h>
#include <string.h>

using namespace std;

int top, s[1000];

inline void push(const int &x) {
    s[++top] = x;
}

inline int pop() {
    top--;
    return s[top+1];
}
int main() {
    int a, b;
    top = 0;
    char str[100];
    while (cin.getline(str, 100)) {
        if ( str[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        } else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(atoi(str));
        }
    }
    cout << pop() << endl;
    return 0;
}